<?php

class HTech_Locale 
{
    private static $_localeOpt = array(
        'es_DO' => 'Español', 'en_US' => 'English', 'fr_CA' => 'Français');
    
    public static function getLocaleOpt()
    {
        return self::$_localeOpt;
    }
    
    public static function setLocaleObj($locale)
    {
        if(Zend_Locale::isLocale($locale)) {
            $objLocale = new Zend_Locale($locale);
        } else {
            $objLocale = new Zend_Locale(Zend_Locale::BROWSER);
        }
        if(self::$_localeOpt[$objLocale->toString()]) {
            Zend_Registry::set('Zend_Locale', new Zend_Locale($objLocale));
        } else {
            Zend_Registry::set('Zend_Locale', new Zend_Locale('en_US'));
        }
    }
    
    public static function setTranslateObj()
    {
        $locale = Zend_Registry::get('Zend_Locale');
        Zend_Registry::set('Zend_Translate', new Zend_Translate(
            array(
                'adapter' => 'gettext',
                'content' => APPLICATION_PATH . '/../languages/'
                             . $locale->getLanguage()
                             . '.mo',
                'locale'  => $locale
            )));
    }
}
